home *** CD-ROM | disk | FTP | other *** search
- (*********************************************************************
- *
- * PROGRAM NAME: PLAYCMF.PAS
- *
- * COMPILER: Borland Turbo Pascal ver. 4 or later
- *
- * DESCRIPTION: Plays a .CMF FM file from the disk using the FMDRV
- * driver (accessed from SBSIM). To run the program,
- * type the following at the command line:
- *
- * PLAYCMF FILENAME
- *
- * Where FILENAME is the drive/path/filename of the .CMF
- * file to play.
- *
- * NOTE: SBSIM driver must be loaded before running this program.
- *
- *********************************************************************)
-
- program playcmf;
- uses dos,crt;
-
- const FM_DRIVER = $01;
-
-
- {$I drvrfunc.pas}
-
- var Command:char;
- UserQuit:boolean;
- FileHandle:integer;
- RetValue:simerr;
- FileName:string;
-
- (********************************************************************)
-
- begin (* main *)
-
- if paramcount <> 1 (* no. of parameters entered on command line *)
- then begin
- writeln('Command line must contain EXACTLY ONE filename parameter!');
- halt; (* Terminate program *)
- end;
-
- (*--- SEE IF SBSIM DRIVER HAS LOADED --*)
- SIMint := FindDvr('SBSIM', $0103); (* Get SBSIM's interrupt no. *)
- if SIMint = 0
- then begin
- writeln('SBSIM driver not loaded!');
- halt; (* Terminate program *)
- end;
-
- (*--- SEE IF FM DRIVER HAS LOADED --------*)
- if (GetDrvrs and FM_DRIVER) <> FM_DRIVER
- then begin
- writeln('FMDRV not loaded!');
- halt;
- end;
-
- (*--- LOAD THE FILE -------------------*)
- FileHandle := DosOpen(paramstr(1), ReadAccess);
- if (FileHandle = -1)
- then begin
- writeln('FILE: ',paramstr(1), ' not successfully opened!');
- halt; (* Terminate program *)
- end;
-
- DosClose(FileHandle);
-
- FileName := paramstr(1); (* copy to string with more space before modifying *)
-
- (*--- StartSnd() LOADS THE FILE AND INITIALIZES THE DRIVER ---*)
- RetValue := StartSnd(FM, AsciiZ(FileName), false, 0);
- if RetValue <> SIMerr_NoErr
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
- halt; (* Terminate program *)
- end;
-
- (*--- PlaySnd() BEGINS PLAYING THE FILE -------------*)
- RetValue := PlaySnd(FM);
- if RetValue <> SIMerr_NoErr
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
- halt; (* Terminate program *)
- end;
-
- clrscr; (* Clear screen *)
- writeln(#10#10#10#10#10' SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:');
- writeln(' (P)ause');
- writeln(' (R)esume');
- writeln(' (Q)uit');
-
- UserQuit := false;
-
- (*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*)
- repeat
- if (keypressed) (* Was a key pressed? *)
- then begin
- Command := upcase(readkey); (* Get char that's in buffer *)
- if Command = 'P'
- then PauseSnd(FM)
- else if Command = 'R'
- then ResumeSnd(FM)
- else if Command = 'Q'
- then UserQuit := true;
- end;
- (* Exit do-while loop if file is done playing or user typed 'Q' *)
- until (UserQuit = true) or (GetSndStat(FM) = 0);
-
-
- (*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*)
- if (GetSndStat(FM) <> 0) and (UserQuit = true)
- then StopSnd(FM);
-
- end.
-
-
-